import numpy as np


# array
# ary = np.array([1,2,3,4,5,6])
# print(ary)
# print(ary.shape)
# print(ary.dtype)
# print(type(ary))
# print(ary * 2)
# print(ary + 100)
# print(ary == 3)

# np.arange(起始值,终止值,步长)
# a = np.arange(0,5,1)
# print(a)
# b = np.arange(0,10,2)
# print(b)

# np.zeros(shape,dtype='类型')
# a = np.zeros(10)
# print(a)
#
# b = np.zeros((3,4))
# print(b)

# np.ones(shape,dtype='类型')
# a = np.ones(10)
# print(a)
# b = np.ones((2,3))
# print(b)

# np.linspace(起始值，终止值，个数)
# ary = np.linspace(-10,10,10)
# print(ary)

# np.random.normal(期望值，标准差，个数)
# ary = np.random.normal(0,1,10)
# print(ary)

# 数组的运算，是拿到每个元素分别运算
# print(ary + ary)
# print(ary * ary)
# 数组的数据间的运算，对应位置，对应计算
# 如果长度不等，不能计算

# np.arange
# ary = arange(1,2,0.1)
# print(ary)

# np.zeros 使用0构建一个数组
# ary = np.zeros(10,dtype='int64')
# print(ary)
# ary = np.zeros((2,2),dtype='int64')
# print(ary) # 看前面有几个方括号，可判断是几维

#np.ones 使用1构建一个数组
# ary = np.ones(10,dtype='int32')
# ary = np.ones((2,2),dtype='int32')
# print(ary)

# ary = np.array([[1,2,3],[4,5,6]])
# np.zeros_like 拿到一个数组的结构，使用0去填充
# res = np.zeros_like(ary)
# print(res)
# np.ones_like 拿到一个数组的结构，使用1去填充
# res1 = np.ones_like(ary)
# print(res1)

# 卷积
#f(t) * g(t-a)



# b = np.arange(1,30)
# print(b)
#
# print(b.mean())
#
# sum = 0
# for i in b:
#     sum += (i - b.mean())
# print(sum)

# 数组的维度：np.ndarray.shape
# ary1 = np.array([1,2,3,4,5,6])
# print(type(ary1),ary1,ary1.shape)
#
# ary2 = np.array([[1,2,3,4,5],
#                  [6,7,8,9,10]])
# print(type(ary2),ary2,ary2.shape)

# 元素的类型：np.ndarray.dtype
# ary = np.array([1,2,3,4,5,6])
# print(type(ary),ary,ary.dtype)
# # 转换ary元素的类型
# b = ary.astype(float)
# print(type(b),b,b.dtype)
# # 转换ary元素的类型
# c = ary.astype(str)
# print(type(c),c,c.dtype)

# 数组元素的个数：np.ndarray.size
ary = np.array([[1,2,3,4],
                [5,6,7,8]])
print(ary.shape,ary.size,len(ary))
